import { lazy } from "react";
import { createBrowserRouter, Outlet } from "react-router-dom";

// import Home from "../views/Home/index";

//路由懒加载
const Home = lazy(() => import("../views/Home/index"));
const Login = lazy(() => import("../views/Login/index"));
const Shopping = lazy(() => import("../views/Shopping/index"));

const getLoader = (v) => {
  console.log("v:", v);
  return "hello 2210A";
};

const routes = [
  {
    path: "/home",
    element: <Home />,
    errorElement: <div>出错啦</div>,
    children: [
      {
        index: true,
        element: <div>首页1111</div>,
      },
      {
        path: "login",
        element: <Login />,
      },
      {
        path: "shopping",
        loader: getLoader,
        element: <Shopping />,
      },
      {
        path: "cate",
        element: <div>分类页面</div>,
      },
    ],
  },
];

export default createBrowserRouter(routes);
